package cn.ac.siom.query.action;

import cn.ac.siom.query.service.CountService;
import cn.ac.siom.query.util.action.DefaultAction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

@SuppressWarnings("unchecked")
@Controller
@RequestMapping(value = "/home/*")
public class SourceCountAction extends DefaultAction {

    @Resource
    private CountService countService;

    @ResponseBody
    @RequestMapping(value = "countSource", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
    public Map findCount(HttpServletRequest request, HttpServletResponse response) throws Exception {
        response.setHeader("Access-Control-Allow-Origin", "*");
        insertAccessinfo(request,"首页资源类型");
        return countService.findAllCount();
    }


    @Override
    public String getText() {
        return null;
    }

}